import { request } from "@/utils/service"
import type * as Login from "./types/login"
import { PageData } from "types/pageData"
import { UserQuery } from "./types/userQuery"
import { Userinfo } from "./types/user"

/** 获取登录验证码 */
export function getLoginCodeApi() {
  return request<Login.LoginCodeResponseData>({
    url: "login/code",
    method: "get"
  })
}

/** 登录并返回 Token */
export function loginApi(data: Login.LoginRequestData) {
  return request<Login.LoginResponseData>({
    url: "api/userinfo/Login",
    method: "post",
    data
  })
}
/**
 * 获取用户列表
 * @param query
 * @returns
 */
export function getUserList(query: UserQuery) {
  return request<ApiResponseData<PageData<Userinfo>>>({
    url: "/api/userinfo/GetUserList",
    method: "get",
    params: query
  })
}
/**
 * 新增
 * @param data
 * @returns
 */
export function create(data: Userinfo) {
  return request<ApiResponseData<boolean>>({
    url: "/api/userinfo/Create",
    method: "post",
    data: data
  })
}
/**
 * 更新
 * @param data
 * @returns
 */
export function update(data: Userinfo) {
  return request<ApiResponseData<boolean>>({
    url: "/api/userinfo/Update",
    method: "post",
    data: data
  })
}
/**
 * 删除
 * @param params
 * @returns
 */
export function del(params: any) {
  return request<ApiResponseData<boolean>>({
    url: "/api/userinfo/Update",
    method: "get",
    params: params
  })
}
